package com.atguigu.gmall.activity.controller;

import com.atguigu.gmall.activity.model.SeckillGoods;
import com.atguigu.gmall.activity.service.SeckillGoodsService;
import com.atguigu.gmall.common.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author: atguigu
 * @create: 2023-07-01 10:53
 */
@RestController
@RequestMapping("/api/activity")
public class SeckillGoodsController {


    @Autowired
    private SeckillGoodsService seckillGoodsService;


    /**
     * 查询当日参与秒杀商品
     *
     * @return
     */
    @GetMapping("/seckill/findAll")
    public Result getSeckillGoods() {
        List<SeckillGoods> list = seckillGoodsService.getSeckillGoods();
        return Result.ok(list);
    }

    /**
     * 查询秒杀商品详情
     *
     * @param skuId
     * @return
     */
    @GetMapping("/seckill/getSeckillGoods/{skuId}")
    public Result getSecGoodsById(@PathVariable("skuId") Long skuId) {
        SeckillGoods seckillGoods = seckillGoodsService.getSecGoodsById(skuId);
        return Result.ok(seckillGoods);
    }
}
